package com.echoplots.domain.ip.domain2ip;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @projectName：74.echoplots-spring-boot-domain-ip
 * 
 * @typeName：GetIp
 * @author：cos
 * @date：2021年2月20日 @version
 * @desc：Java实现通过域名获取IP
 */
public class GetIp {
	public static void main(String[] args) {
		try {
			String name = "showdoc.echoplots.com";
			InetAddress[] addresses = InetAddress.getAllByName(name);
			for (int i = 0; i < addresses.length; i++) {
				System.out.println(name + "[" + i + "]: " + addresses[i].getHostAddress());
			}
		} catch (UnknownHostException uhe) {
			System.err.println("Unable to find: " + args[0]);
		}
	}
}
